package com.linsir.handler;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.reflection.MetaObject;

import java.time.LocalDateTime;


/**
 * @ProjectName:linsir
 * @Package:com.linsir.handler
 * @Title: FillMetaObjectHandler
 * @Description: TODO
 * @Create:2021/5/28 23:23 by @author:Linsir
 * @Update:2021/5/28 23:23 by @author:Linsir
 * @UpdateRemark: 自动填充创建时间和更新时间
 * @Version 1.0.0
 */
@Slf4j
public class FillMetaObjectHandler implements MetaObjectHandler {

    @Override
    public void insertFill(MetaObject metaObject) {
        log.info("start insert fill....");
        this.strictInsertFill(metaObject,"createTime", LocalDateTime.class,LocalDateTime.now())  ;
        this.strictInsertFill(metaObject,"updateTime",LocalDateTime.class,LocalDateTime.now())  ;
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        log.info("start update fill....");
        this.strictInsertFill(metaObject,"updateTime",LocalDateTime.class,LocalDateTime.now())  ;
    }
}
